<?php
include 'header.php';
$column = array();

foreach ($survey as $key=>$subject){
	$total = 0; 
	foreach ($stat['data']['detail'][sprintf('r_%02d', $key+1)] as $v=>$n){
		$total += $v*$n;
	}
	$av = round($total / $stat['data']['count'], 2);
	$column[] = array(
		'label'	=> $subject['subject'],
		'av'	=> $av,
	);
}

?>

<script type="text/javascript" src="/ria/default/charts/charts.js"></script>
<div class="pageBox">
	<div class="archiveBox survey">
		<h1>
			<?php echo $departmentList[$stat['department_id']]['name'];?>问卷报表
		</h1>
		<div class="archiveMemo">
<dl class="innerBox">
	<dt>单位名称：<?php echo $departmentList[$stat['department_id']]['name'];?>，回收问卷数：<?php echo $stat['data']['count'];?></dt>
	
	<dt>数据概览</dt>
	<dd>
		<div id="detail"></div>
		
		<script type="text/javascript">

		   var chart = new FusionCharts("/ria/default/charts/column.swf", "detail", "600", "350", "0", "0");

		   chart.setDataXML("<chart caption='概要统计' xAxisName='选项' yAxisName='分数' showValues='0' decimals='0' formatNumberScale='0'><?php foreach ($column as $item):?><set color='<?php if ($item['av']<=4):?>FF0000<?php elseif ($item['av']>6):?>00FF00<?php else:?>FFFF00<?php endif;?>' label='<?php echo $item['label'];?>' value='<?php echo $item['av'];?>'/><?php endforeach;?></chart>");		   

		   chart.render("detail");

		</script> </td>
		
	</dd>
			
			
	<?php foreach ($survey as $key=>$subject):?>
	<dt><?php echo $subject['subject'];?>，平均得分：
	<?php
		$total = 0; 
		foreach ($stat['data']['detail'][sprintf('r_%02d', $key+1)] as $v=>$n){
			$total += $v*$n;
		}
		$av = round($total / $stat['data']['count'], 2);
		echo $av;
		$column[] = array(
			'label'	=> $subject['subject'],
			'av'	=> $av,
		);
		?>
	</dt>
	<dd>
	<div id="<?php echo sprintf('r_%02d', $key+1);?>"></div>
<script type="text/javascript">
		   var chart = new FusionCharts("/ria/default/charts/charts.swf", "<?php echo sprintf('r_%02d', $key+1);?>", "400", "300", "0", "0");
		  
		   chart.setDataXML("<chart palette='<?php echo $key;?>'><?php foreach ($subject['option'] as $k=>$option): ?><set label='<?php echo $option['label'];?>' value='<?php echo intval($stat['data']['detail'][sprintf('r_%02d', $key+1)][$k]);?>'/><?php endforeach;?></chart>");
		   chart.render("<?php echo sprintf('r_%02d', $key+1);?>");
</script>
	</dd>
	<?php endforeach;?>
	
	
</dl>
		</div>
	</div>
</div>

<?php 
include 'footer.php';
?>